package com.loongtech.bi.manager.game;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.loongtech.bi.entity.game.EntityUserLoginLocation;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
/**
 * 用户登录ip分布
 * @author lihui
 *
 */
@Service
public class UserLoginLocationManager extends ManagerQueryCacheBase<EntityUserLoginLocation> {
	private static final long serialVersionUID = 1L;
	
	/**
	 * 根据开始结束时间查询某个维度的数值
	 * @param dateStart
	 * @param dateEnd
	 * @return
	 */
	public List<Object[]> getUserNumberByAllKindGroupByCityId(Date dateStart, Date dateEnd,String queryPlatform, String queryChannel, String queryServer) {
		return findByQuery(0,9,"select cityid,sum(usernumber) from EntityUserLoginLocation where day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' group by cityid order by sum(usernumber) desc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
	
	/**
	 * 根据开始结束时间查询某个维度的数值
	 * @param dateStart
	 * @param dateEnd
	 * @return
	 */
	public List<Object[]> getUserNumberByAllKindGroupByProvinceId(Date dateStart, Date dateEnd,String queryPlatform, String queryChannel, String queryServer) {
		return findByQuery(0,9,"select provinceid,sum(usernumber) from EntityUserLoginLocation where day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and channelid = '"+queryChannel+"' and serverid = '"+queryServer+"' group by provinceid order by sum(usernumber) desc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
}
